home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-admin / themes.php < prev    next >
Encoding:
PHP Script  |  2005-05-09  |  5.0 KB  |  154 lines

  1. <?php
  2. require_once('admin.php');
  3.  
  4. if ( isset($_GET['action']) ) {
  5.     check_admin_referer();
  6.  
  7.     if ('activate' == $_GET['action']) {
  8.       if (isset($_GET['template'])) {
  9.         update_option('template', $_GET['template']);
  10.       }
  11.  
  12.       if (isset($_GET['stylesheet'])) {
  13.         update_option('stylesheet', $_GET['stylesheet']);
  14.       }
  15.  
  16.         do_action('switch_theme', get_current_theme());
  17.  
  18.       header('Location: themes.php?activated=true');
  19.     }
  20.  }
  21.  
  22. $title = __('Manage Themes');
  23. $parent_file = 'themes.php';
  24. require_once('admin-header.php');
  25. ?>
  26. <?php if ( ! validate_current_theme() ) : ?>
  27. <div class="updated"><p><?php _e('The active theme is broken.  Reverting to the default theme.'); ?></p></div>
  28. <?php elseif ( isset($activated) ) : ?>
  29. <div class="updated"><p><?php _e('New theme activated'); ?></p></div>
  30. <?php endif; ?>
  31.  
  32. <?php
  33. $themes = get_themes();
  34. $current_theme = get_current_theme();
  35. $current_title = $themes[$current_theme]['Title'];
  36. $current_version = $themes[$current_theme]['Version'];
  37. $current_parent_theme = $themes[$current_theme]['Parent Theme'];
  38. $current_template_dir = $themes[$current_theme]['Template Dir'];
  39. $current_stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
  40. $current_template = $themes[$current_theme]['Template'];
  41. $current_stylesheet = $themes[$current_theme]['Stylesheet'];
  42. ?>
  43.  
  44. <div class="wrap">
  45. <h2><?php _e('Current Theme'); ?></h2>
  46. <div id="currenttheme">
  47. <h3><?php printf(__('%1$s %2$s by %3$s'), $current_title, $current_version, $themes[$current_theme]['Author']) ; ?></h3>
  48. <p><?php echo $themes[$current_theme]['Description']; ?></p>
  49. <?php if ($current_parent_theme) { ?>
  50.     <p><?php printf(__('The active theme is <strong>%1$s</strong>.  The template files are located in <code>%2$s</code>.  The stylesheet files are located in <code>%3$s</code>.  <strong>%4$s</strong> uses templates from <strong>%5$s</strong>.  Changes made to the templates will affect both themes.'), $current_theme, $current_template_dir, $current_stylesheet_dir, $current_theme, $current_parent_theme); ?></p>
  51. <?php } else { ?>
  52.     <p><?php printf(__('The active theme is <strong>%1$s</strong>.  The template files are located in <code>%2$s</code>.  The stylesheet files are located in <code>%3$s</code>.'), $current_theme, $current_template_dir, $current_stylesheet_dir); ?></p>
  53. <?php } ?>
  54. </div>
  55.  
  56. <h2><?php _e('Themes Available'); ?></h2>
  57. <?php if ( 1 < count($themes) ) { ?>
  58. <table width="100%" cellpadding="3" cellspacing="3">
  59.     <tr>
  60.         <th><?php _e('Name'); ?></th>
  61.         <th><?php _e('Author'); ?></th>
  62.         <th><?php _e('Description'); ?></th>
  63.         <th></th>
  64.     </tr>
  65. <?php
  66.     $style = '';
  67.  
  68.     $theme_names = array_keys($themes);
  69.     natcasesort($theme_names);
  70.  
  71.     foreach ($theme_names as $theme_name) {
  72.         $template = $themes[$theme_name]['Template'];
  73.         $stylesheet = $themes[$theme_name]['Stylesheet'];
  74.         $title = $themes[$theme_name]['Title'];
  75.         $version = $themes[$theme_name]['Version'];
  76.         $description = $themes[$theme_name]['Description'];
  77.         $author = $themes[$theme_name]['Author'];
  78.  
  79.         if ($template == $current_template && $stylesheet == $current_stylesheet) {
  80.             $action = '<strong>' . __('Active Theme') . '</strong>';
  81.             $current = true;
  82.         } else {
  83.             $action = "<a href='themes.php?action=activate&template=$template&stylesheet=$stylesheet' title='" . __('Select this theme') . "' class='edit'>" . __('Select') . '</a>';
  84.             $current = false;
  85.         }
  86.  
  87.         $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
  88.         if ($current) $style .= $style == 'alternate' ? ' active' : 'active';
  89.         if ($style != '') $style = 'class="' . $style . '"';
  90.  
  91.         echo "
  92.       <tr $style>";
  93. if ( $current )
  94.     echo "<td><strong>$title $version</strong></td>";
  95. else
  96.     echo "<td>$title $version</td>";
  97. echo "
  98.          <td class=\"auth\">$author</td>
  99.          <td class=\"desc\">$description</td>
  100.          <td class=\"togl\">$action</td>
  101.       </tr>";
  102.     }
  103. ?>
  104.  
  105. </table>
  106. <?php
  107. }
  108. ?>
  109.  
  110. <?php
  111. // List broken themes, if any.
  112. $broken_themes = get_broken_themes();
  113. if (count($broken_themes)) {
  114. ?>
  115.  
  116. <h2><?php _e('Broken Themes'); ?></h2>
  117. <p><?php _e('The following themes are installed but incomplete.  Themes must have a stylesheet and a template.'); ?></p>
  118.  
  119. <table width="100%" cellpadding="3" cellspacing="3">
  120.     <tr>
  121.         <th><?php _e('Name'); ?></th>
  122.         <th><?php _e('Description'); ?></th>
  123.     </tr>
  124. <?php
  125.     $theme = '';
  126.     
  127.     $theme_names = array_keys($broken_themes);
  128.     natcasesort($theme_names);
  129.  
  130.     foreach ($theme_names as $theme_name) {
  131.         $title = $broken_themes[$theme_name]['Title'];
  132.         $description = $broken_themes[$theme_name]['Description'];
  133.  
  134.         $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
  135.         echo "
  136.       <tr $theme>
  137.          <td>$title</td>
  138.          <td>$description</td>
  139.       </tr>";
  140.     }
  141. ?>
  142. </table>
  143. <?php
  144. }
  145. ?>
  146.  
  147. <h2><?php _e('Get More Themes'); ?></h2>
  148. <p><?php _e('You can find additional themes for your site in the <a href="http://wordpress.org/extend/themes/">WordPress theme directory</a>. To install a theme you generally just need to upload the theme folder into your <code>wp-content/themes</code> directory. Once a theme is uploaded, you may activate it here.'); ?></p>
  149.  
  150. </div>
  151.  
  152. <?php
  153. include('admin-footer.php');
  154. ?>